package com.ruoyi.member.service.impl;

import java.sql.Timestamp;
import java.time.LocalDate;
import java.util.Date;
import java.util.List;
import java.util.Map;

import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.db.mapper.MemberBaseInfoMapper;
import com.ruoyi.db.domain.MemberBaseInfo;
import com.ruoyi.member.service.IMemberBaseInfoService;

/**
 * 用户基本信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-08-22
 */
@Service
@DataSource(DataSourceType.SLAVE)
public class MemberBaseInfoServiceImpl implements IMemberBaseInfoService 
{
    @Autowired
    private MemberBaseInfoMapper memberBaseInfoMapper;

    /**
     * 查询用户基本信息
     * 
     * @param uid 用户基本信息主键
     * @return 用户基本信息
     */
    @Override
    public MemberBaseInfo selectMemberBaseInfoByUid(Long uid)
    {
        return memberBaseInfoMapper.selectMemberBaseInfoByUid(uid);
    }
    @Override
    public List<Map<String, Object>> selectMemberBaseInfoByChannelCode(MemberBaseInfo memberBaseInfo)
    {
        return memberBaseInfoMapper.selectMemberBaseInfoByChannelCode(memberBaseInfo);
    }
    @Override
    public MemberBaseInfo selectPhoneByUid(Long uid)
    {
        return memberBaseInfoMapper.selectPhoneByUid(uid);
    }
    @Override
    public MemberBaseInfo selectUidByPhone(String phone)
    {
        return memberBaseInfoMapper.selectUidByPhone(phone);
    }

    /**
     * 查询用户基本信息列表
     * 
     * @param memberBaseInfo 用户基本信息
     * @return 用户基本信息
     */
    @Override
    public List<MemberBaseInfo> selectMemberBaseInfoList(MemberBaseInfo memberBaseInfo)
    {
        return memberBaseInfoMapper.selectMemberBaseInfoList(memberBaseInfo);
    }

    @Override
    public List<Map<String, Object>> selectMemberBaseInfoMapList(MemberBaseInfo memberBaseInfo) {
        return memberBaseInfoMapper.selectMemberBaseInfoMapList(memberBaseInfo);
    }

    /**
     * 新增用户基本信息
     * 
     * @param memberBaseInfo 用户基本信息
     * @return 结果
     */
    @Override
    public int insertMemberBaseInfo(MemberBaseInfo memberBaseInfo)
    {
        memberBaseInfo.setCreateTime(DateUtils.getNowDate());
        return memberBaseInfoMapper.insertMemberBaseInfo(memberBaseInfo);
    }

    /**
     * 修改用户基本信息
     * 
     * @param memberBaseInfo 用户基本信息
     * @return 结果
     */
    @Override
    public int updateMemberBaseInfo(MemberBaseInfo memberBaseInfo)
    {
        memberBaseInfo.setUpdateTime(DateUtils.getNowDate());
        return memberBaseInfoMapper.updateMemberBaseInfo(memberBaseInfo);
    }

    /**
     * 批量删除用户基本信息
     * 
     * @param uids 需要删除的用户基本信息主键
     * @return 结果
     */
    @Override
    public int deleteMemberBaseInfoByUids(Long[] uids)
    {
        return memberBaseInfoMapper.deleteMemberBaseInfoByUids(uids);
    }

    /**
     * 删除用户基本信息信息
     * 
     * @param uid 用户基本信息主键
     * @return 结果
     */
    @Override
    public int deleteMemberBaseInfoByUid(Long uid)
    {
        return memberBaseInfoMapper.deleteMemberBaseInfoByUid(uid);
    }

    @Override
    public List<Map<String, Object>> authAndSourceList(String startDate, String endDate, String regAppCode) {
        return memberBaseInfoMapper.authAndSourceList(startDate,endDate,regAppCode);
    }

    @Override
    public List<Map<String, Object>> authAndSourceByWeekList(String startDate, String endDate, String regAppCode) {
        return memberBaseInfoMapper.authAndSourceByWeekList(startDate,endDate,regAppCode);
    }
}
